﻿#region
using System;
using System.ComponentModel;
using System.IO;
using DevExpress.XtraEditors;
using DevTools.Properties;

#endregion

namespace DevTools.AndroidLayoutHelper
{
    public partial class AndroidLayoutHelperForm : XtraForm
    {
        public AndroidLayoutHelperForm()
        {
            InitializeComponent();
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (DesignMode)
                return;

            uscTemplate1.Template = Settings.Default.AndroidLayoutHelper_Template1;
            uscTemplate2.Template = Settings.Default.AndroidLayoutHelper_Template2;
        }

        protected override void OnClosing(CancelEventArgs e)
        {
            uscExcludeList.UpdateSetting();

            Settings.Default.AndroidLayoutHelper_Template1 = uscTemplate1.Template;
            Settings.Default.AndroidLayoutHelper_Template2 = uscTemplate2.Template;

            base.OnClosing(e);
        }

        private void uscFolder_LayoutSelected(object sender, AxmlListControl.LayoutSelectedEventArgs e)
        {
            string filePath = Path.Combine(Settings.Default.AndroidLayoutHelper_AxmlFolder, e.FileName);

            string result1, result2;
            LayoutReader.Read(filePath, uscExcludeList.GetExcludeList(), uscTemplate1.Template, uscTemplate2.Template, out result1, out result2);

            uscResult1.Result = result1;
            uscResult2.Result = result2;

            tcgTab.SelectedTabPage = lcgResult;
        }
    }
}